//
// Created by leisurexi on 11/27/20.
// endian_conv.c
//
#include <stdio.h>
#include <arpa/inet.h>

int main(int argc, char *argv[]) {
    unsigned short host_port = 0x1234;
    unsigned short net_port;
    unsigned long host_addr = 0x12345678;
    unsigned long net_addr;

    net_port = htons(host_port);
    net_addr = htonl(host_addr);

    printf("Host ordered port: %#x \n", host_port);
    printf("Network ordered port: %#x \n", net_port);
    printf("Host ordered addr: %#x \n", host_addr);
    printf("Network ordered addr: %#x \n", net_addr);

}